package com.huahang.fashionpress.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huahang.fashionpress.form.FormAdmin;
import com.huahang.fashionpress.model.Admin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: 阿俊哥 李梦阳
 * @Date: 2019/8/20 15:32
 * @Version 1.0
 */
@Repository
public interface AdminMapper extends BaseMapper<Admin> {

    @Select("SELECT * FROM t_admin ")
    List<Admin> selectAdminList();

    //查询显示页面的管理员信息
    @Select("select t.*,x.nick_name\n" +
            "from t_admin t\n" +
            "left join t_nick x on x.nick_id=t.nick_id")
    List<FormAdmin> SelectFAdminlist();
    //根据管理员Id查管理员
    @Select("select t.*,x.nick_name\n" +
            "from t_admin t\n" +
            "left join t_nick x on x.nick_id=t.nick_id\n" +
            "where admin_id=#{adminid}")
    FormAdmin SelectFAdminByadminId(int adminId);
    //根据角色名查管理员
    @Select("select t.*,x.nick_name\n" +
            "from t_admin t\n" +
            "left join t_nick x on x.nick_id=t.nick_id\n" +
            "where nick_Name=#{nickName}")
    List<FormAdmin> SelectFAdminBynickName(String nickName);
    //根据角色Id查管理员
    @Select("select * from t_admin where nick_id = #{id}")
    Admin selectAdminBynickId(int id);

}
